package com.fzf.blog.modules.api.controller;


import com.fzf.blog.core.annotation.AccessLimit;
import com.fzf.blog.core.util.FcContants;
import com.fzf.blog.core.util.JsonUtil;
import com.fzf.blog.core.util.ReType;
import com.fzf.blog.modules.admin.model.CourseCatalog;
import com.fzf.blog.modules.admin.model.RResource;
import com.fzf.blog.modules.admin.service.ResourceService;
import com.fzf.blog.modules.api.model.CourseCatalogVo;
import com.fzf.blog.modules.api.service.CourseService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/course")
public class ApiCourseController {
    @Autowired
    private CourseService courseService;

    @Autowired
    private ResourceService resourceService;

    @GetMapping("/list")
    @AccessLimit(seconds=1,maxCount=15)
    public Map<String, List<RResource>> menuList(String type) {
        return resourceService.selectAllCourse(type);
    }

    @GetMapping("/catalog/{code}")
    public ReType getCatalogList(@PathVariable("code")Integer code) {
        List<CourseCatalogVo> courseCatalogs = courseService.selectByKcId(code);
        return new ReType(courseCatalogs);
    }


}
